5 * Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.de>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * * Neither the name of Sebastian Bergmann nor the names of his
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
40 * @copyright 2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
43 * @link http://www.phpunit.de/
44 * @since File available since Release 2.3.0
47 require_once 'PHPUnit/Framework.php';
48 require_once 'PHPUnit/Util/Filter.php';
50 PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
53 * A TestListener that logs to a PEAR_Log sink.
57 * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
58 * @copyright 2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
59 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
60 * @version Release: 3.3.17
61 * @link http://www.phpunit.de/
62 * @since Class available since Release 2.1.0
64 class PHPUnit_Util_Log_PEAR implements PHPUnit_Framework_TestListener
74 * @param string $type The type of concrete Log subclass to use.
75 * Currently, valid values are 'console',
76 * 'syslog', 'sql', 'file', and 'mcal'.
77 * @param string $name The name of the actually log file, table, or
78 * other specific store to use. Defaults to an
79 * empty string, with which the subclass will
80 * attempt to do something intelligent.
81 * @param string $ident The identity reported to the log system.
82 * @param array $conf A hash containing any additional configuration
83 * information that a subclass might need.
84 * @param int $maxLevel Maximum priority level at which to log.
86 public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG)
88 if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Log.php')) {
89 PHPUnit_Util_Filesystem::collectStart();
90 require_once 'Log.php';
91 $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel);
93 foreach (PHPUnit_Util_Filesystem::collectEnd() as $blacklistedFile) {
94 PHPUnit_Util_Filter::addFileToFilter($blacklistedFile, 'PHPUNIT');
97 throw new RuntimeException('Log is not available.');
104 * @param PHPUnit_Framework_Test $test
105 * @param Exception $e
108 public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
112 'Test "%s" failed: %s',
121 * A failure occurred.
123 * @param PHPUnit_Framework_Test $test
124 * @param PHPUnit_Framework_AssertionFailedError $e
127 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
131 'Test "%s" failed: %s',
142 * @param PHPUnit_Framework_Test $test
143 * @param Exception $e
146 public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
150 'Test "%s" incomplete: %s',
161 * @param PHPUnit_Framework_Test $test
162 * @param Exception $e
164 * @since Method available since Release 3.0.0
166 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
170 'Test "%s" skipped: %s',
179 * A test suite started.
181 * @param PHPUnit_Framework_TestSuite $suite
182 * @since Method available since Release 2.2.0
184 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
188 'TestSuite "%s" started.',
196 * A test suite ended.
198 * @param PHPUnit_Framework_TestSuite $suite
199 * @since Method available since Release 2.2.0
201 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
205 'TestSuite "%s" ended.',
215 * @param PHPUnit_Framework_Test $test
217 public function startTest(PHPUnit_Framework_Test $test)
221 'Test "%s" started.',
231 * @param PHPUnit_Framework_Test $test
234 public function endTest(PHPUnit_Framework_Test $test, $time)